package com.zenchn.service.impl;

import com.zenchn.dao.TSysWebStyleConfigMapper;
import com.zenchn.dynamic.TSysWebStyleConfigDynamicMapper;
import com.zenchn.generic.GenericDao;
import com.zenchn.generic.GenericServiceImpl;
import com.zenchn.model.TSysWebStyleConfig;
import com.zenchn.model.TSysWebStyleConfigExample;
import com.zenchn.service.WebStyleConfigService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * WebStyleConfigServiceImpl：
 * 系统WEB风格配置实现类
 * @author dingxinfa
 * @date 2020-06-11 16:50
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class WebStyleConfigServiceImpl extends GenericServiceImpl<TSysWebStyleConfig,String, TSysWebStyleConfigExample> implements WebStyleConfigService {


    @Resource
    private TSysWebStyleConfigMapper webStyleConfigMapper;


    @Resource
    private TSysWebStyleConfigDynamicMapper webStyleConfigDynamicMapper;

    @Override
    public GenericDao<TSysWebStyleConfig, String, TSysWebStyleConfigExample> getDao() {
        return webStyleConfigMapper;
    }


    @Override
    public Boolean verifyName(String styleConfigId, String accessParameter) {

        TSysWebStyleConfigExample example = new TSysWebStyleConfigExample();
        TSysWebStyleConfigExample.Criteria criteria = example.createCriteria();
        criteria.andAccessParameterEqualTo(accessParameter);

        if (null != styleConfigId && !"".equals(styleConfigId.trim())) {
            criteria.andStyleConfigIdNotEqualTo(styleConfigId.trim());
        }

        return webStyleConfigMapper.countByExample(example) <= 0;
    }
}
